<?php
	include_once 'autoload.php';
	

	session_start();

	$ctl = new EditPictureCtl();
	$ctl->checkLogged();
	$ctl->checkNotReadonly();
	$ctl->proceed();
	
	$header = new Header();
	$header->render('Update Profile');

	$form = $ctl->getEditPictureForm();
	
	$id = $form->getId();
	$name = $form->getName();
	$adding = $form->isAdding();
	$addTitle = $adding ? 'Add' : 'Edit';
	$addValue = $adding ? 'yes' : '';
	
	$albumId = $form->getAlbumId();
	$albumName = htmlspecialchars($form->getAlbumName());
	
?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="pagename" value="editpicture" id="pgid">
<input type="hidden" name="metname" value="" id="metid">

<input type="hidden" name="id" value="<?php echo $id; ?>" >
<input type="hidden" name="albumId" value="<?php echo $albumId; ?>" >
<input type="hidden" name="albumName" value="<?php echo $form->getAlbumName(); ?>">
<input type="hidden" name="adding" value="<?php echo $addValue; ?>">

<h2><?php echo $addTitle; ?> Picture</h2>
<h2>Album: <?php echo $albumName; ?></h2>
<table cellpadding="8" cellspacing="0" class="list">
	<tr>
		<td>Picture name:</td>
		<td><input type="text" name="name" value="<?php echo $name; ?>"></td>
	</tr>
	<tr>
		<td>Upload file:</td>
		<td><input type="file" name="picture" id="file"></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
		<div style="width: 300px;">if you are editing a picture and you don't
		upload a new file, then the old one will be preserved, however in
		adding mode, the file is of course mandatory.</div>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
			<input type="button" value="Submit" onclick="triggerform('submit')" class="enter">
			<input type="button" value="Cancel" onclick="triggerform('cancel')" class="escape">
		</td>
	</tr>
</table>
</form>
<?php
	$footer = new Footer();
	$footer->render();
?>
